package com.code.wflow.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ggh
 * @date 2022/11/11
 */
public final class RequestContext {
    private Map<String, Object> contextMap = new HashMap<>(5);

    /**
     * 解析token获取的用户id
     */
    public static final String X_USER_ID = "USER_ID";

    /**
     * 解析token获取的用户角色
     */
    public static final String ADMIN = "ADMIN";

    private Map<String, Object> getContextMap() {
        return contextMap;
    }

    public void setUserId(Long userId) {
        getContextMap().put(X_USER_ID, userId);
    }

    public Long getUserId() {
        return (Long) getContextMap().get(X_USER_ID);
    }

    public void setAdmin(Boolean admin) {
        getContextMap().put(ADMIN, admin);
    }

    public Boolean isAdmin() {
        return (Boolean) getContextMap().get(ADMIN);
    }
}
